using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
public class SetQQGroupForm : Form
{
	private Button buttonClr;
	private Button buttonDelete;
	private Button buttonSchQQGroup;
	private Button buttonUpdate;
	private DataGridView dataGridViewQQGroup;
	public QQInviteUtil qqInviteUtil;
	private GroupBox groupBox1;
	private IContainer icontainer_0;
	private Label label1;
	private Label label2;
	public string string_0 = "";
	public string self_qq = "";
	private TextBox textBoxGroupName;
	private TextBox textBoxQQGroup;
	public SetQQGroupForm(string string_2, QQInviteUtil gclass28_1)
	{
		try
		{
			this.self_qq = string_2;
			this.qqInviteUtil = gclass28_1;
			this.InitializeComponent();
			this.method_2();
			this.method_0();
		}
		catch (Exception ex)
		{
			MessageBox.Show("[SetQQGroupForm]出错，" + ex.ToString());
		}
	}
	private void buttonClr_Click(object sender, EventArgs e)
	{
		this.method_3();
	}
	private void buttonDelete_Click(object sender, EventArgs e)
	{
		try
		{
			if (this.dataGridViewQQGroup.CurrentCell != null)
			{
				QQqun qQqun = new QQqun();
				qQqun.num = this.dataGridViewQQGroup[0, this.dataGridViewQQGroup.CurrentCell.RowIndex].Value.ToString();
				this.qqInviteUtil.delete_qq_qun(qQqun, out this.string_0);
				this.method_3();
				string string_ = "select * from qqgroupmng where owner='" + this.self_qq + "';";
				this.method_1(string_);
			}
		}
		catch (Exception ex)
		{
			MessageBox.Show("[buttonDelete_Click]出错，" + ex.ToString());
		}
	}
	private void buttonSchQQGroup_Click(object sender, EventArgs e)
	{
		try
		{
			string text = "select * from qqgroupmng ";
			if (!this.textBoxQQGroup.Text.Trim().Equals(""))
			{
				text = string.Concat(new string[]
				{
					text,
					" where owner='",
					this.self_qq,
					"' and qqgroup='",
					this.textBoxQQGroup.Text.Trim(),
					"'"
				});
			}
			else
			{
				if (!this.textBoxGroupName.Text.Trim().Equals(""))
				{
					text = string.Concat(new string[]
					{
						text,
						" where owner='",
						this.self_qq,
						"' and groupname='",
						this.textBoxGroupName.Text.Trim(),
						"'"
					});
				}
			}
			this.method_1(text);
		}
		catch (Exception ex)
		{
			MessageBox.Show("[buttonSchQQGroup_Click]出错，" + ex.ToString());
		}
	}
	private void buttonUpdate_Click(object sender, EventArgs e)
	{
		try
		{
			if (!this.textBoxQQGroup.Text.Trim().Equals("") && !this.textBoxGroupName.Text.Trim().Equals(""))
			{
				QQqun qQqun = new QQqun();
				qQqun.num = this.textBoxQQGroup.Text.Trim();
				qQqun.name = this.textBoxGroupName.Text.Trim();
				qQqun.owner = this.self_qq;
				if (!this.qqInviteUtil.delete_qq_qun(qQqun, out this.string_0))
				{
					MessageBox.Show("更新删除出错，" + this.string_0);
				}
				else
				{
					if (!this.qqInviteUtil.method_8(qQqun, out this.string_0))
					{
						MessageBox.Show("更新插入出错，" + this.string_0);
					}
					else
					{
						string string_ = "select * from qqgroupmng where owner='" + this.self_qq + "';";
						this.method_1(string_);
					}
				}
			}
		}
		catch (Exception ex)
		{
			MessageBox.Show("[buttonUpdate_Click]出错，" + ex.ToString());
		}
	}
	private void dataGridViewQQGroup_Click(object sender, EventArgs e)
	{
		try
		{
			if (this.dataGridViewQQGroup.CurrentCell != null)
			{
				this.textBoxQQGroup.Text = this.dataGridViewQQGroup[0, this.dataGridViewQQGroup.CurrentCell.RowIndex].Value.ToString();
				this.textBoxGroupName.Text = this.dataGridViewQQGroup[1, this.dataGridViewQQGroup.CurrentCell.RowIndex].Value.ToString();
			}
		}
		catch (Exception ex)
		{
			MessageBox.Show("[dataGridViewQQGroup_Click]出错，" + ex.ToString());
		}
	}
	protected override void Dispose(bool disposing)
	{
		if (disposing && this.icontainer_0 != null)
		{
			this.icontainer_0.Dispose();
		}
		base.Dispose(disposing);
	}
	private void InitializeComponent()
	{
		ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(SetQQGroupForm));
		this.buttonUpdate = new Button();
		this.label1 = new Label();
		this.textBoxQQGroup = new TextBox();
		this.textBoxGroupName = new TextBox();
		this.label2 = new Label();
		this.buttonDelete = new Button();
		this.dataGridViewQQGroup = new DataGridView();
		this.groupBox1 = new GroupBox();
		this.buttonClr = new Button();
		this.buttonSchQQGroup = new Button();
		((ISupportInitialize)this.dataGridViewQQGroup).BeginInit();
		this.groupBox1.SuspendLayout();
		base.SuspendLayout();
		this.buttonUpdate.Location = new Point(396, 18);
		this.buttonUpdate.Name = "buttonUpdate";
		this.buttonUpdate.Size = new Size(43, 23);
		this.buttonUpdate.TabIndex = 0;
		this.buttonUpdate.Text = "更新";
		this.buttonUpdate.UseVisualStyleBackColor = true;
		this.buttonUpdate.Click += new EventHandler(this.buttonUpdate_Click);
		this.label1.AutoSize = true;
		this.label1.Location = new Point(6, 25);
		this.label1.Name = "label1";
		this.label1.Size = new Size(53, 12);
		this.label1.TabIndex = 1;
		this.label1.Text = "QQ群号：";
		this.textBoxQQGroup.Location = new Point(57, 20);
		this.textBoxQQGroup.Name = "textBoxQQGroup";
		this.textBoxQQGroup.Size = new Size(87, 21);
		this.textBoxQQGroup.TabIndex = 2;
		this.textBoxGroupName.Location = new Point(201, 20);
		this.textBoxGroupName.Name = "textBoxGroupName";
		this.textBoxGroupName.Size = new Size(131, 21);
		this.textBoxGroupName.TabIndex = 4;
		this.label2.AutoSize = true;
		this.label2.Location = new Point(154, 23);
		this.label2.Name = "label2";
		this.label2.Size = new Size(53, 12);
		this.label2.TabIndex = 3;
		this.label2.Text = "群名称：";
		this.buttonDelete.Location = new Point(443, 18);
		this.buttonDelete.Name = "buttonDelete";
		this.buttonDelete.Size = new Size(44, 23);
		this.buttonDelete.TabIndex = 5;
		this.buttonDelete.Text = "删除";
		this.buttonDelete.UseVisualStyleBackColor = true;
		this.buttonDelete.Click += new EventHandler(this.buttonDelete_Click);
		this.dataGridViewQQGroup.AllowUserToAddRows = false;
		this.dataGridViewQQGroup.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
		this.dataGridViewQQGroup.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
		this.dataGridViewQQGroup.Location = new Point(7, 55);
		this.dataGridViewQQGroup.Name = "dataGridViewQQGroup";
		this.dataGridViewQQGroup.RowTemplate.Height = 23;
		this.dataGridViewQQGroup.Size = new Size(545, 262);
		this.dataGridViewQQGroup.TabIndex = 6;
		this.dataGridViewQQGroup.Click += new EventHandler(this.dataGridViewQQGroup_Click);
		this.groupBox1.Controls.Add(this.buttonClr);
		this.groupBox1.Controls.Add(this.buttonSchQQGroup);
		this.groupBox1.Controls.Add(this.textBoxQQGroup);
		this.groupBox1.Controls.Add(this.label1);
		this.groupBox1.Controls.Add(this.buttonUpdate);
		this.groupBox1.Controls.Add(this.buttonDelete);
		this.groupBox1.Controls.Add(this.textBoxGroupName);
		this.groupBox1.Controls.Add(this.label2);
		this.groupBox1.Location = new Point(7, -3);
		this.groupBox1.Name = "groupBox1";
		this.groupBox1.Size = new Size(545, 52);
		this.groupBox1.TabIndex = 7;
		this.groupBox1.TabStop = false;
		this.buttonClr.Location = new Point(490, 18);
		this.buttonClr.Name = "buttonClr";
		this.buttonClr.Size = new Size(46, 23);
		this.buttonClr.TabIndex = 7;
		this.buttonClr.Text = "清空";
		this.buttonClr.UseVisualStyleBackColor = true;
		this.buttonClr.Click += new EventHandler(this.buttonClr_Click);
		this.buttonSchQQGroup.Location = new Point(349, 18);
		this.buttonSchQQGroup.Name = "buttonSchQQGroup";
		this.buttonSchQQGroup.Size = new Size(44, 23);
		this.buttonSchQQGroup.TabIndex = 6;
		this.buttonSchQQGroup.Text = "搜索";
		this.buttonSchQQGroup.UseVisualStyleBackColor = true;
		this.buttonSchQQGroup.Click += new EventHandler(this.buttonSchQQGroup_Click);
		base.AutoScaleDimensions = new SizeF(6f, 12f);
		base.AutoScaleMode = AutoScaleMode.Font;
		base.ClientSize = new Size(561, 329);
		base.Controls.Add(this.groupBox1);
		base.Controls.Add(this.dataGridViewQQGroup);
		base.FormBorderStyle = FormBorderStyle.FixedSingle;
		base.Icon = (Icon)componentResourceManager.GetObject("$this.Icon");
		base.MaximizeBox = false;
		base.MinimizeBox = false;
		base.Name = "SetQQGroupForm";
		base.StartPosition = FormStartPosition.CenterScreen;
		this.Text = "设置QQ群";
		((ISupportInitialize)this.dataGridViewQQGroup).EndInit();
		this.groupBox1.ResumeLayout(false);
		this.groupBox1.PerformLayout();
		base.ResumeLayout(false);
	}
	public void method_0()
	{
		try
		{
			string string_ = "select * from qqgroupmng where owner='" + this.self_qq + "';";
			this.method_1(string_);
		}
		catch (Exception ex)
		{
			MessageBox.Show("[reloadQQGroup]出错，" + ex.ToString());
		}
	}
	public void method_1(string string_2)
	{
		try
		{
			this.dataGridViewQQGroup.Rows.Clear();
			ArrayList arrayList = this.qqInviteUtil.query_qq_qun(string_2, out this.string_0);
			if (arrayList == null)
			{
				MessageBox.Show("加载配置QQ群出错！" + this.string_0);
			}
			else
			{
				int num = 0;
				foreach (QQqun qQqun in arrayList)
				{
					DataGridViewRow dataGridViewRow = new DataGridViewRow();
					this.dataGridViewQQGroup.Rows.Add(dataGridViewRow);
					this.dataGridViewQQGroup.Rows[num].HeaderCell.Value = string.Concat(num + 1);
					this.dataGridViewQQGroup[0, num].Value = qQqun.num;
					this.dataGridViewQQGroup[1, num].Value = qQqun.name;
					num++;
				}
			}
		}
		catch (Exception ex)
		{
			MessageBox.Show("[selectQQGroup]出错，" + ex.ToString());
		}
	}
	private void method_2()
	{
		try
		{
			this.dataGridViewQQGroup.TopLeftHeaderCell.Value = "编号";
			DataGridViewTextBoxColumn dataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
			dataGridViewTextBoxColumn.HeaderText = "QQ群号";
			this.dataGridViewQQGroup.Columns.Add(dataGridViewTextBoxColumn);
			DataGridViewTextBoxColumn dataGridViewTextBoxColumn2 = new DataGridViewTextBoxColumn();
			dataGridViewTextBoxColumn2.HeaderText = "群名称";
			this.dataGridViewQQGroup.Columns.Add(dataGridViewTextBoxColumn2);
		}
		catch (Exception ex)
		{
			MessageBox.Show("[initQQGroupDataGridView]出错，" + ex.ToString());
		}
	}
	private void method_3()
	{
		this.textBoxQQGroup.Text = "";
		this.textBoxGroupName.Text = "";
		this.dataGridViewQQGroup.Rows.Clear();
	}
}
